package com.woniuxy.yuekeuser.controller;


import com.woniuxy.yuekeuser.common.Result;
import com.woniuxy.yuekeuser.model.CampsitePicture;
import com.woniuxy.yuekeuser.service.ICampsitePictureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Freedom
 * @since 2020-11-03
 */
@RestController
@Slf4j
@CrossOrigin("*")
public class CampsitePictureController {
    @Autowired
    private ICampsitePictureService iCampsitePictureService;

    @GetMapping("getIndexPicture")
    public Result getIndexPicture(){
        log.info("执行首页的轮播图");
        List<CampsitePicture> allCampsitePicture = iCampsitePictureService.getAllCampsitePicture();
        if (allCampsitePicture.size()<6){
            return Result.success(allCampsitePicture);
        }else {
            return Result.success(allCampsitePicture.subList(0,5));
        }
    }
}

